package com.huawei.appgallery.search.ui.card;

import android.content.Context;
import android.view.View;
import android.view.ViewStub;
import android.widget.LinearLayout;
import com.huawei.appgallery.foundation.card.base.normal.bean.NormalCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.search.ui.cardbean.SearchSpecialTopicItemCardBean;
import huawei.widget.HwTextView;
import java.util.ArrayList;
import java.util.List;
import o.cgz;
import o.chy;
import o.cuv.b;
import o.dof;
import o.CollectCheck;

public class SearchSpecialTopicItemCard extends BaseCompositeItemCard {
    private LinearLayout ʻ;
    private ViewStub ʼ;
    private ViewStub ʽ;
    private HwTextView ˊॱ;
    private List<SearchSpecialTopicItemSubCard> ˋ = new ArrayList();
    private SearchSpecialTopicItemSubCard ˋॱ;
    private SearchSpecialTopicItemSubCard ˏॱ;
    private SearchSpecialTopicItemSubCard ͺ;
    private HwTextView ॱˊ;
    private String ॱˋ;
    private ViewStub ॱॱ;
    private int ॱᐝ = 0;
    private View ᐝ;

    public SearchSpecialTopicItemCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        this.ʻ = (LinearLayout) view.findViewById(b.ˈॱ);
        this.ˊॱ = (HwTextView) this.ʻ.findViewById(b.ʽᐝ);
        this.ॱˊ = (HwTextView) this.ʻ.findViewById(b.ʼᐝ);
        this.ॱॱ = (ViewStub) view.findViewById(b.ˋˊ);
        this.ʽ = (ViewStub) view.findViewById(b.ˋˋ);
        this.ʼ = (ViewStub) view.findViewById(b.ˋᐝ);
        this.ˏॱ = new SearchSpecialTopicItemSubCard(view.getContext());
        this.ˋॱ = new SearchSpecialTopicItemSubCard(view.getContext());
        this.ͺ = new SearchSpecialTopicItemSubCard(view.getContext());
        this.ᐝ = view.findViewById(b.ॱˎ);
        ʽ(view);
        return this;
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        if (cardBean instanceof SearchSpecialTopicItemCardBean) {
            SearchSpecialTopicItemCardBean searchSpecialTopicItemCardBean = (SearchSpecialTopicItemCardBean) cardBean;
            ˋ(this.ʻ, searchSpecialTopicItemCardBean.ʽ(), searchSpecialTopicItemCardBean.ꜟ());
            List ॱ = searchSpecialTopicItemCardBean.ॱ();
            if (CollectCheck.isEmpty(ॱ)) {
                ॱ(this.ʻ);
                ॱ(this.ˏॱ.ˋ());
                ॱ(this.ˋॱ.ˋ());
                ॱ(this.ͺ.ˋ());
            } else {
                this.ˋ.clear();
                this.ॱˋ = searchSpecialTopicItemCardBean.ॱˉ();
                this.ॱᐝ = ॱ.size() > 3 ? 3 : ॱ.size();
                SearchSpecialTopicItemSubCard searchSpecialTopicItemSubCard;
                ViewStub viewStub;
                NormalCardBean normalCardBean;
                boolean z;
                if (this.ॱᐝ == 1) {
                    searchSpecialTopicItemSubCard = this.ˏॱ;
                    viewStub = this.ॱॱ;
                    normalCardBean = (NormalCardBean) ॱ.get(0);
                    if (ˎ() && searchSpecialTopicItemCardBean.ॱㆍ()) {
                        z = true;
                    } else {
                        z = false;
                    }
                    ॱ(searchSpecialTopicItemSubCard, viewStub, normalCardBean, true, z);
                    ॱ(this.ˋॱ.ˋ());
                    ॱ(this.ͺ.ˋ());
                } else if (ॱ.size() == 2) {
                    ॱ(this.ˏॱ, this.ॱॱ, (NormalCardBean) ॱ.get(0), false, false);
                    searchSpecialTopicItemSubCard = this.ˋॱ;
                    viewStub = this.ʽ;
                    normalCardBean = (NormalCardBean) ॱ.get(1);
                    if (ˎ() && searchSpecialTopicItemCardBean.ॱㆍ()) {
                        z = true;
                    } else {
                        z = false;
                    }
                    ॱ(searchSpecialTopicItemSubCard, viewStub, normalCardBean, true, z);
                    ॱ(this.ͺ.ˋ());
                } else if (ॱ.size() >= 3) {
                    ॱ(this.ˏॱ, this.ॱॱ, (NormalCardBean) ॱ.get(0), false, false);
                    ॱ(this.ˋॱ, this.ʽ, (NormalCardBean) ॱ.get(1), false, false);
                    searchSpecialTopicItemSubCard = this.ͺ;
                    viewStub = this.ʼ;
                    normalCardBean = (NormalCardBean) ॱ.get(2);
                    if (ˎ() && searchSpecialTopicItemCardBean.ॱㆍ()) {
                        z = true;
                    } else {
                        z = false;
                    }
                    ॱ(searchSpecialTopicItemSubCard, viewStub, normalCardBean, true, z);
                }
            }
            if (ˎ()) {
                this.ᐝ.setVisibility(8);
            } else {
                this.ᐝ.setVisibility(0);
            }
        }
    }

    private void ॱ(View view) {
        if (view != null) {
            view.setVisibility(8);
        }
    }

    private void ॱ(SearchSpecialTopicItemSubCard searchSpecialTopicItemSubCard, ViewStub viewStub, NormalCardBean normalCardBean, boolean z, boolean z2) {
        View ˋ = searchSpecialTopicItemSubCard.ˋ();
        if (searchSpecialTopicItemSubCard.ˋ() == null) {
            ˋ = viewStub.inflate();
            searchSpecialTopicItemSubCard.ˏ(ˋ);
            searchSpecialTopicItemSubCard.ˎ(ˋ);
        }
        normalCardBean.ˊ(z);
        normalCardBean.ʻ(z2);
        normalCardBean.ˋˋ(this.ॱˋ);
        searchSpecialTopicItemSubCard.ˏ((CardBean) normalCardBean);
        ˋ.setVisibility(0);
        ॱ(searchSpecialTopicItemSubCard);
    }

    public void ॱ(chy o_chy) {
        super.ॱ(o_chy);
        if (o_chy != null) {
            int i = 0;
            while (i < ˋ().size() && (ˋ().get(i) instanceof SearchSpecialTopicItemSubCard)) {
                ((SearchSpecialTopicItemSubCard) ˋ().get(i)).ॱ(o_chy);
                i++;
            }
        }
    }

    public List<SearchSpecialTopicItemSubCard> ˋ() {
        return this.ˋ;
    }

    public void ॱ(SearchSpecialTopicItemSubCard searchSpecialTopicItemSubCard) {
        this.ˋ.add(searchSpecialTopicItemSubCard);
    }

    private void ˋ(View view, String str, String str2) {
        if (view != null) {
            if (dof.ॱ(str) || dof.ॱ(str2)) {
                view.setVisibility(8);
                return;
            }
            view.setVisibility(0);
            this.ˊॱ.setText(str);
            this.ॱˊ.setText(str2);
        }
    }
}
